#!/bin/bash
###SHELLPACK preamble libmicro-smallbatches-bench 1

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargEnd
###SHELLPACK monitor_hooks

###SHELLPACK check_install_required libmicro-smallbatches-${VERSION}
###SHELLPACK init_complete

cd $SHELLPACK_SOURCES/libmicro-smallbatches-${VERSION}-installed || die "Failed to cd to libmicro directory"

COMMON="-E -C 0 -D 30000 -B 100 -L -S -W"

while read A B C; do
	monitor_pre_hook $LOGDIR_RESULTS $A-$B
	if [ -f bin/$A ]; then
		eval bin/$A $COMMON -N "$B" $C 2>&1 > $LOGDIR_RESULTS/$B.log
	fi
	monitor_post_hook $LOGDIR_RESULTS $A-$B
done <<EOT
write		write_t100k	-s 100k			-f $TFILE
writev		writev_t10k	-s 10k		-f $TFILE
writev		writev_t100k	-s 100k			-f $TFILE
memset	memset_1m	-s 1m
memset	memset_10m	-s 10m
memset	memsetP2_10m	-s 10m -P 2
malloc	mallocT2_100k	-s 100k -g 10 -T 2
memcpy	memcpy_1m	-s 1m
memcpy	memcpy_10m	-s 10m
mmap	mmap_wz128k	-l 128k -w	-f /dev/zero
mmap	mmap_wa128k	-l 128k -w	-f MAP_ANON
munmap	unmap_wz128k	-l 128k	-w	-f /dev/zero
munmap	unmap_wa128k	-l 128k	-w	-f MAP_ANON
mprotect	mprot_tw4m	-l 4m -w -t -f /dev/zero
cascade_mutex	c_mutex_10	-T 10
cascade_mutex	c_mutex_200	-T 200
cascade_lockf	c_lockf_10 -P 10
cascade_lockf	c_lockf_200 -P 200
cascade_fcntl	c_fcntl_10 -P 10
cascade_fcntl	c_fcntl_200 -P 200
cascade_cond	c_cond_10	-T 10
cascade_cond	c_cond_200	-T 200
connection	connection
connection	conn_accept -a
connection	conn_connect -c
close_tcp	close_tcp
poll	poll_1000	-n 1000
poll	poll_w1000	-n 1000	-w 100
select	select_1000	-n 1000
select	select_w1000	-n 1000 -w 100
exit	exit
EOT

exit $SHELLPACK_SUCCESS
